package com.alipay.app.groupmeal.standard.ui.c.pre;

import android.content.Context;
import android.os.Build;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.constraintlayout.widget.ConstraintLayout;

import com.alipay.app.groupmeal.standard.R;
import com.alipay.app.groupmeal.standard.base.BasePresentation;
import com.alipay.app.groupmeal.standard.offline.bean.FkBean;
import com.alipay.app.groupmeal.standard.ui.c.SelectPayActivity;

import io.reactivex.rxjava3.disposables.Disposable;

public class ReadCardPre extends BasePresentation {

    private Context mContext;

    private TextView mTvCloseTime;

    ConstraintLayout loginCl;

    LinearLayout linear;

    private TextView msgTv;
    private TextView cardNoTv;
    private TextView nameTv;
    private TextView btyeTv;
    private TextView kyeTv;
    private int type;

    //5074
    public ReadCardPre(Context outerContext, Display display, int type) {
        super(outerContext, display);
        mContext = outerContext;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            getWindow().setType(WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY);
        } else {
            getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
        }
        this.type = type;

    }


    @Override
    protected int getLayoutId() {
        switch (type) {

            case 1:
                return R.layout.pre_activity_checkfk_ft2;
            default:
                return R.layout.pre_activity_checkfk_ft2;
        }

    }

    @Override
    protected void initView() {
        mTvCloseTime = findViewById(R.id.tv_close_time);
        loginCl = findViewById(R.id.loadingCon);
        linear = findViewById(R.id.linear);
        msgTv = findViewById(R.id.msgTv);
        cardNoTv = findViewById(R.id.cardNoTv);
        nameTv = findViewById(R.id.nameTv);
        btyeTv = findViewById(R.id.btyeTv);
        kyeTv = findViewById(R.id.kyeTv);

    }

    public void showSec(String sec) {
        mTvCloseTime.setText(sec);
    }

    @Override
    protected void initData() {

    }

    public void showRes(FkBean fkBean) {
        loginCl.setVisibility(View.GONE);
        linear.setVisibility(View.VISIBLE);
        if (fkBean == null) {
            msgTv.setText("非法卡");
            cardNoTv.setVisibility(View.GONE);
            nameTv.setVisibility(View.GONE);
            btyeTv.setVisibility(View.GONE);
            kyeTv.setVisibility(View.GONE);
        } else {
            cardNoTv.setText("卡号：" + fkBean.getCardno());
            nameTv.setText("姓名：" + fkBean.getName());
            btyeTv.setText("补贴余额：" + fkBean.getBtye());
            kyeTv.setText("自购余额：" + fkBean.getKye());
        }
    }

    public void showError(String msg) {
        loginCl.setVisibility(View.GONE);
        linear.setVisibility(View.VISIBLE);
        msgTv.setText(msg);
        cardNoTv.setVisibility(View.GONE);
        nameTv.setVisibility(View.GONE);
        btyeTv.setVisibility(View.GONE);
        kyeTv.setVisibility(View.GONE);
    }
}
